import 'package:dmz/base/pageWidget/base_stateful_widget.dart';
import 'package:dmz/business/login/contorller/login_main_controller.dart';
import 'package:dmz/business/login/widgets/login_widgets.dart';
import 'package:dmz/utils/keyboard_util.dart';
import 'package:flutter/material.dart';
import 'package:get/get_state_manager/src/rx_flutter/rx_obx_widget.dart';

import '../../../base/widget/back_image_widget.dart';

class LoginPage extends BaseStatefulWidget<LoginPageController> {
  @override
  bool showTitleBar() => false;

  @override
  bool onleyShowBackButton() => true;

  @override
  Widget buildContent(BuildContext context) {
    return GestureDetector(
        onTap: () => KeyboardUtils.hideKeyboard(context),
        child: BackImageWidget(
            child: Column(
                mainAxisAlignment: MainAxisAlignment.start,
                children: [
              logoWidget(context),
              inputWdigets(),
              otherActionWidgets(),
              otherLogin()
            ])));
  }

  ///logo
  Widget logoWidget(context) {
    return LoginWidgets.logoWidget(context);
  }

  ///输入部分
  Widget inputWdigets() {
    return Obx(() => Column(children: [
          LoginWidgets.loginChanegBtns(controller.isCodeLG.value,
              (bool type) => controller.isCodeLG.value = type),
          LoginWidgets.inputWdiegts(controller.isCodeLG.value,
              photneController: controller.photneController,
              passwordController: controller.passwordController,
              codeController: controller.codeController,
              sendCode: controller.snedCode,
              countdownStr: '${controller.counter.value}s',
              obscureText: controller.obscureText.value,
              passwordClick: () =>
                  controller.obscureText.value = !controller.obscureText.value,
              codeType: controller.snedCodeType.value,
              netxt: controller.login)
        ]));
  }

  ///忘记密码、政策协议
  Widget otherActionWidgets() {
    return Obx(() => LoginWidgets.otherActionWidgets(
        controller.agreed.value,
        controller.isCodeLG.value,
        () => controller.agreed.value = !controller.agreed.value,
        controller.showPrivacyPolicy,
        forgetClick: controller.turnFroeget));
  }

  ///其他登录
  Widget otherLogin() {
    return LoginWidgets.otherLoginWidgt();
  }
}
